home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
ARGONET
/
PD
/
PROGRAMMING
/
DESKLIBC
/
SOURCES.ZIP
/
DeskLib
/
!DLSources
/
Libraries
/
Str
/
c
/
LeafName
< prev
next >
Wrap
Text File
|
1995-07-22
|
2KB
|
47 lines
/*
#### # # # #
# # # # # The FreeWare C library for
# # ## ### # # # # ### RISC OS machines
# # # # # # # # # # # ___________________________________
# # #### ### ## # # # #
# # # # # # # # # # Please refer to the accompanying
#### ### #### # # ##### # ### documentation for conditions of use
________________________________________________________________________
File: Misc.Leafname.c
Author: Copyright © 1994 Erik de Kort
Version: 1.01 (26 Jun 1994)
Purpose: Determine the leaf-name of a file given a legal pathname
Mods: 12 Jul 1995 - JPS - Changed name to Str_LeafName.
*/
#include "DeskLib:Str.h"
/* Str_LeafName() ----------------------------------------------------------
* Return a pointer to the leaf of 'FullPath'.
* Note that this pointer is within the 'FullPath' string.
* If no separator (dot or colon) is encountered in FullPath, then the
* pointer FullPath is returned.
*
* It is assumed that if any colons appear, then you either have a proper
* pathname (SCSI::...) in which case a dot will appear before the leafname,
* or you're using a path MyPath:FileName, so : is treated the same as .
*/
extern char *Str_LeafName(char *path)
{
char *leaf, ch = '.';
do
{
if (ch == '.' || ch == ':')
leaf = path ;
}
while ( (ch = *(path++)) != '\0') ;
return(leaf) ;
/* cc warns 'leaf' may be used before being set */
}